/**
 */
package ms.unicorn.dsl.unicornDSL.impl;

import ms.unicorn.dsl.unicornDSL.UnicornDSLPackage;
import ms.unicorn.dsl.unicornDSL.XExpression;
import ms.unicorn.dsl.unicornDSL.XFeatureCall;
import ms.unicorn.dsl.unicornDSL.XForControlVariable;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>XFor Control Variable</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XForControlVariableImpl#isNew <em>New</em>}</li>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XForControlVariableImpl#getFeature <em>Feature</em>}</li>
 *   <li>{@link ms.unicorn.dsl.unicornDSL.impl.XForControlVariableImpl#getValue <em>Value</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class XForControlVariableImpl extends IdentifiedElementImpl implements XForControlVariable
{
  /**
   * The default value of the '{@link #isNew() <em>New</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isNew()
   * @generated
   * @ordered
   */
  protected static final boolean NEW_EDEFAULT = false;

  /**
   * The cached value of the '{@link #isNew() <em>New</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #isNew()
   * @generated
   * @ordered
   */
  protected boolean new_ = NEW_EDEFAULT;

  /**
   * The cached value of the '{@link #getFeature() <em>Feature</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFeature()
   * @generated
   * @ordered
   */
  protected XFeatureCall feature;

  /**
   * The cached value of the '{@link #getValue() <em>Value</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getValue()
   * @generated
   * @ordered
   */
  protected XExpression value;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected XForControlVariableImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return UnicornDSLPackage.Literals.XFOR_CONTROL_VARIABLE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isNew()
  {
    return new_;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setNew(boolean newNew)
  {
    boolean oldNew = new_;
    new_ = newNew;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UnicornDSLPackage.XFOR_CONTROL_VARIABLE__NEW, oldNew, new_));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public XFeatureCall getFeature()
  {
    return feature;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetFeature(XFeatureCall newFeature, NotificationChain msgs)
  {
    XFeatureCall oldFeature = feature;
    feature = newFeature;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UnicornDSLPackage.XFOR_CONTROL_VARIABLE__FEATURE, oldFeature, newFeature);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setFeature(XFeatureCall newFeature)
  {
    if (newFeature != feature)
    {
      NotificationChain msgs = null;
      if (feature != null)
        msgs = ((InternalEObject)feature).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UnicornDSLPackage.XFOR_CONTROL_VARIABLE__FEATURE, null, msgs);
      if (newFeature != null)
        msgs = ((InternalEObject)newFeature).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - UnicornDSLPackage.XFOR_CONTROL_VARIABLE__FEATURE, null, msgs);
      msgs = basicSetFeature(newFeature, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UnicornDSLPackage.XFOR_CONTROL_VARIABLE__FEATURE, newFeature, newFeature));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public XExpression getValue()
  {
    return value;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetValue(XExpression newValue, NotificationChain msgs)
  {
    XExpression oldValue = value;
    value = newValue;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UnicornDSLPackage.XFOR_CONTROL_VARIABLE__VALUE, oldValue, newValue);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setValue(XExpression newValue)
  {
    if (newValue != value)
    {
      NotificationChain msgs = null;
      if (value != null)
        msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UnicornDSLPackage.XFOR_CONTROL_VARIABLE__VALUE, null, msgs);
      if (newValue != null)
        msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - UnicornDSLPackage.XFOR_CONTROL_VARIABLE__VALUE, null, msgs);
      msgs = basicSetValue(newValue, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, UnicornDSLPackage.XFOR_CONTROL_VARIABLE__VALUE, newValue, newValue));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XFOR_CONTROL_VARIABLE__FEATURE:
        return basicSetFeature(null, msgs);
      case UnicornDSLPackage.XFOR_CONTROL_VARIABLE__VALUE:
        return basicSetValue(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XFOR_CONTROL_VARIABLE__NEW:
        return isNew();
      case UnicornDSLPackage.XFOR_CONTROL_VARIABLE__FEATURE:
        return getFeature();
      case UnicornDSLPackage.XFOR_CONTROL_VARIABLE__VALUE:
        return getValue();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XFOR_CONTROL_VARIABLE__NEW:
        setNew((Boolean)newValue);
        return;
      case UnicornDSLPackage.XFOR_CONTROL_VARIABLE__FEATURE:
        setFeature((XFeatureCall)newValue);
        return;
      case UnicornDSLPackage.XFOR_CONTROL_VARIABLE__VALUE:
        setValue((XExpression)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XFOR_CONTROL_VARIABLE__NEW:
        setNew(NEW_EDEFAULT);
        return;
      case UnicornDSLPackage.XFOR_CONTROL_VARIABLE__FEATURE:
        setFeature((XFeatureCall)null);
        return;
      case UnicornDSLPackage.XFOR_CONTROL_VARIABLE__VALUE:
        setValue((XExpression)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case UnicornDSLPackage.XFOR_CONTROL_VARIABLE__NEW:
        return new_ != NEW_EDEFAULT;
      case UnicornDSLPackage.XFOR_CONTROL_VARIABLE__FEATURE:
        return feature != null;
      case UnicornDSLPackage.XFOR_CONTROL_VARIABLE__VALUE:
        return value != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (new: ");
    result.append(new_);
    result.append(')');
    return result.toString();
  }

} //XForControlVariableImpl
